package homework;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class MyFrame extends JFrame {

    private Doudizhu doudizhu = new Doudizhu();
    private ImageIcon playerIcon1 = new ImageIcon("src\\homework\\img\\11.jpg");
    private ImageIcon playerIcon2 = new ImageIcon("src\\homework\\img\\99.jpg");
    private ImageIcon playerIcon3 = new ImageIcon("src\\homework\\img\\88.jpg");

    public MyFrame(Doudizhu doudizhu){

        JLabel jLabel1 = new JLabel(playerIcon1);
        JLabel jLabel2 = new JLabel(playerIcon2);
        JLabel jLabel3 = new JLabel(playerIcon3);

        jLabel1.setBounds(40,280,60,60);
        jLabel2.setBounds(1090,280,60,60);
        jLabel3.setBounds(570,670,60,60);

        JLabel jLabelText = new JLabel("地主牌");
        jLabelText.setBounds(560,50,120,30);
        jLabelText.setFont(new Font("宋体",Font.PLAIN,25));

        for (int i = 0; i < 17;i ++){
            int num = (doudizhu.pukeArrayList.get(i).getSize()) / 10;
            int num2 = 5 -(doudizhu.pukeArrayList.get(i).getSize()) % 10;

            JLabel jLabel = new JLabel(new ImageIcon("src\\homework\\img\\" + num + "_" + num2 + ".jpg"));
            jLabel.setBounds(130,520-(i * 30),105,150);
            this.add(jLabel);
        }

        for (int i = 17; i < 34;i ++){
            int num = (doudizhu.pukeArrayList.get(i).getSize()) / 10;
            int num2 = 5 - (doudizhu.pukeArrayList.get(i).getSize()) % 10;
            JLabel jLabel = new JLabel(new ImageIcon("src\\homework\\img\\" + num + "_" + num2 + ".jpg"));
            jLabel.setBounds(950,1030-(i * 30),105,150);
            this.add(jLabel);
        }

        for (int i = 34; i < 51;i ++){
            int num = (doudizhu.pukeArrayList.get(i).getSize()) / 10;
            int num2 = 5 -(doudizhu.pukeArrayList.get(i).getSize()) % 10;
            JLabel jLabel = new JLabel(new ImageIcon("src\\homework\\img\\" + num + "_" + num2 + ".jpg"));
            jLabel.setBounds(780 - ((i-34) * 30),500,105,150);
            this.add(jLabel);
        }
        for (int i = 51; i < 54;i ++){
            int num = (doudizhu.pukeArrayList.get(i).getSize()) / 10;
            int num2 = 5 -(doudizhu.pukeArrayList.get(i).getSize()) % 10;
            JLabel jLabel = new JLabel(new ImageIcon("src\\homework\\img\\" + num + "_" + num2 + ".jpg"));
            jLabel.setBounds(570 - ((i-51) * 30),100,105,150);
            this.add(jLabel);
        }




        this.add(jLabel1);
        this.add(jLabel2);
        this.add(jLabel3);
        this.add(jLabelText);

        //设置窗口的关闭策略
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        //设置布局管理器为空
        this.setLayout(null);

        //设置窗口大小
        this.setSize(1200,800);

        //设置标题栏文字
        this.setTitle("爷的窗口");

        //设置窗口的默认打开位置居中
        this.setLocationRelativeTo(null);

        //设置窗口为显示状态
        this.setVisible(true);



    }


    public void paiXu(int start, int end){
        for (int i = start; i < end;i ++){
            int num = (doudizhu.pukeArrayList.get(i).getSize()) / 10;
            int num2 = (doudizhu.pukeArrayList.get(i).getSize()) % 10;
            JLabel jLabel = new JLabel(new ImageIcon("img\\" + num + "_" + num2 + ".jpg"));
            jLabel.setBounds(130,520-(i * 30),105,150);
            this.add(jLabel);
        }
    }


}
